package com.int_tech.MessageCodeAll.dao;

import com.int_tech.MessageCodeAll.entity.CodeA2;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * Created by liubochao on 2018/6/22.
 */
public interface CodeA2Dao extends JpaRepository<CodeA2,Integer> {
    List<CodeA2> findByLatLikeAndStatus(String lat, int i);

    List<CodeA2> findByLatAndStatus(String lat, int i);

    List<CodeA2> findByStatus(int i);

//    List<CodeA2> findByCarNumberAndStatusAndCreateTimeAfter(String carNumber, int i, Date createTime);

    @Query("select c from CodeA2 c where c.carNumber=?1 and c.status=?2 and c.createdTime<?3 order by c.createdTime desc ")
    List<CodeA2> findByCarNumberAndStatusAndCreateTimeBefore(String carNumber, int i, Date createTime);

    @Query("select c from CodeA2 c where c.carNumber=?1 and c.status=?2 and c.createdTime>?3 order by c.createdTime asc ")
    List<CodeA2> findByCarNumberAndStatusAndCreateTimeAfter(String carNumber, int i, Date createTime);
}
